home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / tool / helper / src / eup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  3.5 KB  |  133 lines

  1. /*
  2. +--------------------------------------------------------+
  3. |          display port               output port        |
  4. | +-----------------------+ +--------------------------+ |
  5. | | A B C D E F G H RS TW | | A B C D E F G H RS TW DT | |
  6. | +-----------------------+ +--------------------------+ |
  7. | 1 ***********************   9 ***********************  |
  8. | 2 ***********************  10 ***********************  |
  9. | 3 ***********************  11 ***********************  |
  10. | 4 ***********************  12 ***********************  |
  11. | 5 ***********************  13 ***********************  |
  12. | 6 ***********************  14 ***********************  |
  13. | 7 ***********************  15 ***********************  |
  14. | 8 ***********************  16 ***********************  |
  15. |                               [PLAY]  [STOP]  [ END ]  |
  16. +--------------------------------------------------------+
  17. */
  18. #include    <stdio.h>
  19. #include    <stdlib.h>
  20. #include    "graphic.h"
  21. #include    "coldef.h"
  22.  
  23. #define    EUP_X1        (23*8)
  24. #define    EUP_Y1        180
  25. #define    EUP_X2        (57*8-4)
  26. #define    EUP_Y2        260
  27.  
  28. #define    EUP_BAR_SIZE    64
  29. #define    EUP_BAR_X1    (EUP_X1+8)
  30. #define    EUP_BAR_Y1    (EUP_Y1+8)
  31. #define    EUP_BAR_X2    (EUP_X1+11)
  32. #define    EUP_BAR_Y2    (EUP_BAR_Y1+EUP_BAR_SIZE)
  33.  
  34. #define    TRK_MAX        32
  35.  
  36. static    BLOCK    *save = NULL;
  37. static    char    *old_ptr = NULL;
  38. static    int    old_tick = 0;
  39. static    int    note_max[TRK_MAX];
  40. static    int    note_vol[TRK_MAX];
  41.  
  42. void    EUP_open()
  43. {
  44.     int     n;
  45.  
  46.     MOS_disp(OFF);
  47.     save = DSP_push_vram(EUP_X1,EUP_Y1,EUP_X2,EUP_Y2);
  48.     DSP_opbox(EUP_X1,EUP_Y1,EUP_X2,EUP_Y2);
  49.     DSP_wbox(EUP_X1,EUP_Y1,EUP_X2,EUP_Y2,LINE_COL,FILD_COL,M_PSET);
  50.  
  51.     for ( n = 0 ; n < TRK_MAX ; n++ ) {
  52.     note_vol[n] = note_max[n] = (-1);
  53.     DSP_box( EUP_BAR_X1+n*8-1, EUP_BAR_Y1-1,
  54.          EUP_BAR_X2+n*8+1, EUP_BAR_Y2+1,
  55.          7, M_PSET);
  56.     }
  57.     old_tick = tick_timer = 0;
  58.     old_ptr = NULL;
  59. }
  60. void    EUP_close()
  61. {
  62.     DSP_pop_vram(save);
  63.     DSP_clbox(EUP_X1,EUP_Y1,EUP_X2,EUP_Y2);
  64.     MOS_disp(ON);
  65. }
  66. void    EUP_note_on(int trk, int vol)
  67. {
  68.     int n;
  69.     int x1, x2;
  70.  
  71.     vol = ((vol * EUP_BAR_SIZE) / 127) & 0xFFFE;
  72.  
  73.     x1 = EUP_BAR_X1 + trk * 8;
  74.     x2 = EUP_BAR_X2 + trk * 8;
  75.  
  76.     if ( note_vol[trk] >= 0 && note_max[trk] > vol )
  77.         DSP_box(x1, EUP_BAR_Y2 - note_max[trk],
  78.         x2, EUP_BAR_Y2 - vol,
  79.         7, M_PSET);
  80.  
  81.     DSP_line(x1, EUP_BAR_Y2 - vol,
  82.          x2, EUP_BAR_Y2 - vol,
  83.          2, M_PSET);
  84.  
  85.     for ( n = vol - 2 ; n >= 0 && n >= note_vol[trk] ; n -= 2 ) {
  86.     DSP_line(x1, EUP_BAR_Y2 - n,
  87.              x2, EUP_BAR_Y2 - n,
  88.              10, M_PSET);
  89.     }
  90.  
  91.     note_vol[trk] = note_max[trk] = vol;
  92. }
  93. void    EUP_chk(char *ptr)
  94. {
  95.     int     n;
  96.  
  97.     if ( old_tick < tick_timer ) {
  98.     for ( n = 0 ; n < TRK_MAX ; n++ ) {
  99.         if ( note_vol[n] >= 2 ) {
  100.         note_vol[n] -= 2;
  101.         DSP_line(EUP_BAR_X1 + n * 8,
  102.              EUP_BAR_Y2 - note_vol[n],
  103.              EUP_BAR_X2 + n * 8,
  104.              EUP_BAR_Y2 - note_vol[n],
  105.              7, M_PSET);
  106.         } else if ( note_vol[n] == 0 ) {
  107.             DSP_line(EUP_BAR_X1 + n * 8,
  108.              EUP_BAR_Y2 - note_max[n],
  109.              EUP_BAR_X2 + n * 8,
  110.              EUP_BAR_Y2 - note_max[n],
  111.                  7, M_PSET);
  112.         note_vol[n] = (-1);
  113.         }
  114.     }
  115.     old_tick += 16;
  116.     }
  117.  
  118.     if ( ptr == NULL )
  119.     return;
  120.  
  121.     if ( old_ptr == NULL )
  122.     old_ptr = ptr;
  123.  
  124.     while ( old_ptr < ptr ) {
  125.     if ( (*old_ptr & 0xF0) == 0x90 )
  126.         EUP_note_on(old_ptr[4] / 4, old_ptr[5] & 127);
  127. /******************
  128.         EUP_note_on(old_ptr[1] % TRK_MAX, old_ptr[5] & 127);
  129. *******************/
  130.     old_ptr += 6;
  131.     }
  132. }
  133.